﻿using System;
using System.Linq;
using LinqExpressions = System.Linq.Expressions;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Microsoft.Silverlight.Testing;
using System.Collections.Generic;
using System.ComponentModel.Composition;
using System.Reflection;
using System.Windows.Threading;

using Caliburn.Micro.BikeWizard.Tests.BaseClasses;
using Caliburn.Micro.BikeWizard.Tests.Utils;
using Caliburn.Micro.BikeWizard.Views;
using Caliburn.Micro.BikeWizard.Utils;

namespace Caliburn.Micro.Wizard.Tests
{
    /// <summary>
    /// </summary>
    [TestClass]
    public class CoroutineExecutorTests : TestBase
    {
        #region Tests
        [TestMethod]
        [Asynchronous]
        public void SingleCoroutineExecutor()
        {
            new CoroutineExecutor(
                new Sleeper(2),
                new ActionResult((result) =>
                {
                    result.SetComplete(this);
                }),
                SetTestComplete()).Execute(null);
        }

        [TestMethod]
        [Asynchronous]
        public void NestedCoroutineExecutors()
        {
            new CoroutineExecutor(
                new Sleeper(1),
                new CoroutineExecutor(
                        new Sleeper(1), 
                        SetTestComplete())).Execute(null);
        }

        [TestMethod]
        [Asynchronous]
        [ExpectedException(typeof(AssertFailedException))]
        public void NestedCoroutineExecutorsWithAssertFailedException()
        {
            new CoroutineExecutor(
                new Sleeper(1),
                new CoroutineExecutor(
                        new Sleeper(1),
                        new ActionResult(
                            (actionResult)=>
                            {
                                Assert.AreEqual(1, 2);
                            }),
                        SetTestComplete())).Execute(null);
        }
        #endregion
    }
}
